////////////////////////setting///////////////////////////////////////
	function Setting(){}

	//初始化
	Setting.init = function(subModule,argmt){
	   // CM.init();
		//$('div.nav #header_setting').attr("class","active");
	   if(argmt){
		   Setting.loadsubModule(subModule,argmt);
	   }else{
		   Setting.loadsubModule(subModule);
	   }
	
	}
	// 加载对应的模块。
	Setting.loadsubModule = function(subModule,argmt){
		if(subModule==undefined || subModule==null || subModule==''){
			return;
		}
	
		if(argmt){
			subModule.list(argmt);	// 此处不严谨。不是每个模块，都有list这个方法。
		}else{
			
			subModule.list();
		}
	}
	
///////////////////////////////////////operate/////////////////////////////////////////////
	   function Operate(){}
	   Operate.pg = new Page('listtb');// 列表页面
	  // 查询
	   Operate.search = function(){
		  var zone = 'dataView';
		  var form='schForm';
		  var action='../setting/operate.php?method=listQry';    
	      url = action;
	      if (Operate.pg.params) {url +=Operate.pg.params;}        
	      submitSearch('schForm',url+rnd(),'dataView',function(){
	    	  	Operate.pg.init();
	      });
	  }
	   Operate.pg.query = Operate.search;

	   Operate.list = function(){
	      $('#main').load('../setting/operate.php?method=list'+rnd(),'',function(){
	    	  Help.show(740,0);
	    	  Operate.search();
	      });
	  }

///////////////////////user/////////////////////////////////////////////
 	function User(){}
    User.pg = new Page('listtb');//列表页面
    //查询
    User.search = function(){
	    var zone = 'dataView';
	    var form='schForm';
	    var action='../setting/user.php?method=listQry';    
        url = action;
        if (User.pg.params) {url +=User.pg.params;}        
        $('#dataView').load(url+rnd(),'',function(){
            User.pg.init();
        });      
    }
    User.pg.query = User.search;
    
    //打开新增子用户页面
    User.goAdd=function(){
        CM.open('../setting/user.php?method=add'+rnd(),{title:'新增用户',size:WINDOW_M},function(){	
        	Help.show(737,1);
        });
    }
    //判断.只能为汉字,字母,数字
    User.chk = function(str){
		var reg = /^(\w|[\u4E00-\u9FA5])*$/;
		if(arr=str.match(reg)){			
			return true;
		}else{
			CM.alert("用户名只允许为英文，数字和汉字的混合,\n请检查是否前后有空格或者其他符号");			
			return false;
		} 
    }
    //检查用户名是否重复
    User.chkUserName = function(){
        if ($("#userName").val()==''){
        return;
        }
    
	    $.ajax({url:'../setting/user.php?method=isNotUniqueUserName',
	           type:"post",
	           dataType:"json",
	           data:'userName='+$("#userName").val(),	           
	           success:function(data){
				       if (data.code=='1'){
				          CM.alert('对不起,这个用户名已经被人用了,请另选一个.');
				          $("#userName").focus();
				          return;
				       }
			  }
	    });	    	    	    	        	
	}

    //新增用户
    User.save = function(me){
	      //校验账号信息
	      //alert($('#userName,addForm'));
	      if ($('#userName,userAddForm').val()==null||$('#userName,userAddForm').val()==''){
	          CM.alert('用户名不能为空!');
	          $('#userName,userAddForm').focus();
	          return;
	      }
          //alert($('#userName').val());
          if (!User.chk($('#userName,userAddForm').val())) return;
	      if (getStrLen($('#userName,userAddForm').val())<3){
	          CM.alert('用户名不能小于3个字母');
	          $('#userName,userAddForm').focus();
	          return;
	      }
	       if (getUserNameLen($('#userName,userAddForm').val())>18){
	          CM.alert('用户名不能大于18个字母(1个汉字相当于3个字母.)');
	          $('#userName,userAddForm').focus();
	          return;
	       }
       
 	       if ($('#password,userAddForm').val()==''){
		      CM.alert('密码不能为空！');
		      $('#password,userAddForm').focus();
		      return;
		   }
       
	       if ($('#password,userAddForm').val()!=$('#password2,userAddForm').val()){
		      CM.alert('两次密码不一致！');
		      $('#password2').focus();
		      return;
		   }      
       
    
       submitSave('userAddForm','../setting/user.php?method=doAdd'+rnd(),function(data){
    	   CM.close(me);
		   User.search();
       });
    }
    
    //打开修改页面
    User.goEdit=function(oid){
        CM.open('../setting/user.php?method=edit&oid='+oid+rnd(),{title:'修改用户',size:WINDOW_M},function(){
        	Help.show(739,1);
        });
    }
               
    //修改
    User.update = function(me){
       
	   if ($('#password,userEditForm').val()!=''||$('#password2,userEditForm').val()!=''){
	       if ($('#password,userEditForm').val()!=$('#password2,userEditForm').val()){
		      CM.alert('两次密码不一致！');
		      $('#password2').focus();
		      return;
		   }
	   }
      
       
       submitSave('userEditForm','../setting/user.php?method=doEdit'+rnd(),function(){
    		CM.close(me);
    		User.search();
       });      
    }


 // 删除
    User.onDelete = function(oid){
       deleteRow1('../setting/user.php?method=delete&oid='+oid+rnd(),"确定要删除吗？",function(){
    		User.search();
       });       
    }
        
    User.list = function(){
        $('#main').load('../setting/user.php?method=list'+rnd(),'',function(){
           Help.show(736,0);
           User.search();
        });
    }  
    
    User.goEditPassword = function(){
        $('#main').load('../setting/password.php?method=edit'+rnd(),'',function(){
        	Help.show(749,0);
        });
    }  
    
    //重置密码
    User.resetPassowrd = function(){
    	$("input[type=password]").each(function(){
 		   this.value='';
 	    });
    	$('#oldPassword').focus();
    }

    
    //修改密码
    User.editPassowrd = function(me){
       submitSave('pwdEditForm','../setting/password.php?method=doEdit'+rnd(),function(data){
    	   $("input[type=password]").each(function(){
    		   this.value='';
    	   });
       });
    } 
    
    //停用
    User.onStop = function(oid,status){
    	if(!oid){
    		if(!getRdoVal('oid')){
    			CM.alert('请选择一条记录');
    			return;
    		}
    		oid=getRdoVal('oid');
    	}
//    	if(!confirm("确认 启用/停用该子用户")){
//    		return;
//    	}
    	CM.confirm('确认启用/停用该子用户',function(){
    	submitReq('../setting/user.php?method=stop&oid='+oid+rnd(),function(data){
    		if(data.code==1){
    			if(data.msg!=''){
    				CM.alert(data.msg);
    			}
    		}
     		User.search();
        });  
        });
     } 
    
    User.goEditSubUserPWD=function(){
    	var oid=getRdoVal('oid');
    	if(!oid){
    		CM.alert("请选择一条记录");
    		return;
    	}
    	
    	CM.open('../setting/user.php?method=goEditSubUserPWD&userId='+oid+rnd(),{title:'初始化子用户密码',size:WINDOW_M},function(){
    		Help.show(738,1);
    	});
    }
    
    User.editSubUserPWD=function(me){
    	submitSave('pwdEditForm','../setting/user.php?method=editSubUserPWD',function(data){
    		
    		if(data.code=='1'){
    			CM.alert(data.msg);
    		}else{
    			CM.close(me);
    		}
    	});
    }
    
    //恢复停用的user
    User.doRepair = function(oid){
    	CM.confirm('确认恢复该用户吗？',function(){
    		submitReq('../setting/user.php?method=repair&oid='+oid+rnd(),function(){
    			Recycle.search('userRecycleQry');
    		});
    	});
    }
    
      
///////////////////////payee/////////////////////////////////////////////
    function Payee(){}
 	Payee.pg = new Page('listtb');// 列表页面
 	var payeeChange='';//全局变量
 	var groupCode ='';
 	 
 	Payee.defindSearch = function (){
 		groupCode = $('div.body #groupCode').val();
 		Payee.search(groupCode);
 	}
 	
    // 查询
 	Payee.search = function(cate){
	    var zone = 'dataView';
	    var form='schForm';
	    var action='../setting/payee.php?method=listQry';
	    if(cate!='search'){
	    	groupCode=cate;
	    	$('div.body #groupCode').val(groupCode);
	    	$('div.searchbar div.base_condition #payeeName').val('');
	    }
	    if(cate){
	    	//action=action+'&groupCode='+groupCode;
	    	action=action;
	    }
	    payeeChange=cate;
        url = action;
        if (Payee.pg.params) {url +=Payee.pg.params;}   
        submitSearch(form,url+rnd(),zone,function(){Payee.pg.init();});          
    }
 	Payee.pg.query = Payee.defindSearch;

    Payee.opener = ''; //暂存select对象
 	Payee.refresh = function(){} //保存完人员后，回调函数
    // 打开人员页面
 	Payee.goAdd=function(me){
 		
 		$('div.searchbar div.base_condition #payeeName').val('');
 		if(me){
 			if($(me).val()!='add'){
 				return;
 			}
 			$(me).get(0).selectedIndex=0; //恢复到第一个选项目
 			Payee.opener = me;
 		}else{
 			Payee.opener='';
 		}
 		/*
 		if(parm=='init'){
 			 CM.open('../setting/payee.php?method=add&oid='+payeeChange,{title:'新增人员',size:WINDOW_M},function(){
 				PayeePicker.search();
 	        });
 		}else{
	        
 		}*/
 		CM.open('../setting/payee.php?method=add&oid='+payeeChange,{title:'新增人员',size:WINDOW_M},function(){
        	Help.show(4037,1);
        });
    }

    // 新增成员
 	Payee.save = function(me,flag,cate){
 		
       submitSave('payeeAddForm','../setting/payee.php?method=doAdd'+rnd(),function(data){
    	   if(flag!='1'){
        	   CM.close(me);
    	   }
    	   if(Payee.opener){
	    	   $.getJSON(ctx+"/setting/payee.php?method=getPayeeOption"+rnd(),'',function(data){  
			         if (data.returnCode=='2'){
			        	var dataObj=eval(data.data);
			        	var options = '';
			        	$.each(dataObj,function(a,b){
			        		options=options+'<option value='+b.payeeId+'>'+b.payeeName+'</option>';
			        	})
			        	
			        	$(Payee.opener).find('option').each(function(){
			        		
			        		if($(this).val()==''){
			        			options='<option value=>'+$(this).text()+'</option>'+options;
			        		}
			        		if($(this).val()=='add'){
			        			options=options+'<option value='+$(this).val()+'>'+$(this).text()+'</option>';
			        		}
			        	});
			        	$(Payee.opener).empty();
			        	$(Payee.opener).addClass($(Payee.opener).attr('class')); //IE 下select的class需要重新加载
			    		$(Payee.opener).append(options);
			         }
			    })
			    
    	   }else{
    		   Payee.search(cate);
    	   }
    	   
       });
    }
    /**
     * 保存并继续
     * @return
     */
 	Payee.saveAndNext=function(me,flag,cate){
 		Payee.save(me,flag,cate);
 	}
    // 打开修改页面
 	Payee.goEdit=function(oid){
        CM.open('../setting/payee.php?method=edit&oid='+oid+rnd(),{title:'修改人员',size:WINDOW_M},function(){
        	Help.show(4038,1);
        });
    }
               
   // 保存修改
 	Payee.update = function(me){
       submitSave('payeeEditForm','../setting/payee.php?method=doEdit'+rnd(),function(){
    	   CM.close(me);
    	   Payee.search('');
    	   
//    	   $('div#searchbar').find(":text[name='payeeName']").val('');
//    	   var payeeGroupId=$('form#payeeEditForm').find("select[name='payeeGroupId']").val();
//    	   //取到open页面的option，处理
//    	   var opts=$("div#searchbar").find("select[name='payeeGroupId']").find('option');
//    	   opts.each(function(){
//    		   if(this.value==payeeGroupId){
//    			   $(this).attr("selected","selected");
//    			   CM.close(me);
//    			   Payee.search();
//    			   return;
//    		   }
//    	   });
       });      
    }

    // 删除
 	Payee.onDelete = function(oid){
// 		if(!oid){
//         	 if(getRadioValue('oid')){
//         		 oid=getRadioValue('oid')
//         	 }else{
//         		 return false;
//         	 }
//          }
//    	if(!confirm("确认 启用/停用该人员")){
//    		return;
//    	}
 		
 		CM.confirm('确定要删除吗？',function(){
    	submitReq('../setting/payee.php?method=delete&oid='+oid+rnd(),function(data){
//    		if(data.code==1){
//    			if(data.msg!=''){
//    				CM.alert(data.msg);
//    			}
//    		}
     		Payee.search('');
        });    
 		});
    }   
    
    // 设置为默认
 	Payee.setDefault = function(oid){
	       submitReq('../setting/payee.php?method=setDefault&oid='+oid+rnd(),function(){
	    	   Payee.search('');
	       }); 
    }   
    
    Payee.list = function(cate){
        $('#main').load('../setting/payee.php?method=list'+rnd(),'',function(){
        	Help.show(4032,0);
        	Payee.search(cate);
        });
    }  
    
 // 恢复 
 	Payee.doRepair= function(oid){
 		CM.confirm('确认恢复该人员吗?',function(){
 			submitReq('../setting/payee.php?method=repair&oid='+oid+rnd(),function(data){
 	    		Recycle.search('payeeRecycleQry');
 	        }); 
 		});
    }
 	
 
    
    
 // 恢复 
 	Payee.doRepair= function(oid){
 		CM.confirm('确认恢复该人员吗?',function(){
 			submitReq('../setting/payee.php?method=repair&oid='+oid+rnd(),function(data){
 	    		Recycle.search('payeeRecycleQry');
 	        }); 
 		});
    }
    
    // /////////////////////Tag/////////////////////////////////////////////
	function Tag(){}
	Tag.afterSave = function(){}
	Tag.pg = new Page('listtb');// 列表页面
   // 查询
	Tag.search = function(cate){
	    var zone = 'dataView';
	    var form='schForm';
	    var action='../setting/tag.php?method=listQry&showInvisible='+cate;    
       url = action;
       if (Tag.pg.params) {url +=Tag.pg.params;}        
       submitSearch('schForm',url+rnd(),'dataView',function(){Tag.pg.init();});
   }
	Tag.pg.query = Tag.search;

   
   // 打开新增页面
	Tag.goAdd=function(){
   	   $('div.searchbar div.base_condition #tagName').val("");
       CM.open('../setting/tag.php?method=add'+rnd(),{title:'新增标签',size:WINDOW_M},function(){	
    	   Help.show(4040,0);
       });
   }

   // 新增成员
	Tag.save = function(me){
      submitSave('tagAddForm','../setting/tag.php?method=doAdd'+rnd(),function(date){
    	  console.log(date);
    	if(date.date!='2'){
    		CM.close(me);
       		Tag.search();
    	}
      });
   }
   
   // 打开修改页面
	Tag.goEdit=function(oid){
       CM.open('../setting/tag.php?method=edit&oid='+oid+rnd(),{title:'修改标签',size:WINDOW_M},function(){
    	   Help.show(4041,0);
       });
   }
              
  // 保存修改
	Tag.update = function(me){
	  CM.alert("修改后关联的账目中的标签会自动更新。您确定要修改此标签吗？",function(){
		  submitSave('tagEditForm','../setting/tag.php?method=doEdit'+rnd(),function(){
		   		CM.close(me);
		   		Tag.search();
		      });   
	  });
         
   }

   //隐藏、显示
	Tag.showInvisible = function(oid,invisible){
		 var oids;
		 if(oid){
			  oids=oid;
		 }else{
			   if(!getCheckValue('oid')){
				   return;
			   }
			   oids=getCheckValue('oid');
		}
		var alterInvisible ;
    	if(invisible=='1'){
    		alterInvisible = '启用';
    	}else {
    		alterInvisible = '停用'; 
    	}
    	
		CM.confirm('确定要'+alterInvisible+'选中标签？',function(){
			submitReq("../setting/tag.php?method=showInvisible&status="+invisible+rnd()+"&oids="+oids,function(data){
				Tag.search();
			})
		});
				
   }   
	
	// 删除项目
	Tag.onDelete= function(oid){
//		if(!confirm('确定要删除此项目吗?')){
//			return;
//		}
		CM.confirm('如果此标签已经记过账了，关联账目的中标签会自动删除。您确定要删除吗？',function(){
		   var url="../setting/tag.php?method=delete"+rnd();
		   url=url+"&oid="+oid;
		   submitReq(url,function(data){
			   Tag.search();
		   });
		});
   }	
   
   
   Tag.list = function(){
       $('#main').load('../setting/tag.php?method=list'+rnd(),'',function(){
    	   Help.show(4039,0);
       	   Tag.search();
       });
   }  
   
   //恢复标签
   Tag.doRepair = function(oid){
	   CM.confirm('你确定要恢复此标签吗？',function(){
		   submitReq('../setting/tag.php?method=repair&oid='+oid+rnd(),function(){
			   Recycle.search('tagRecycleQry');
		   });
	   });
   }
    
  
  //////////////////////////fundInfo///////////////////////////////////////////
	function FundInfo(){} 
    FundInfo.pg = new Page('listtb');//列表页面
    //查询
    FundInfo.search = function(){
	    var zone = 'dataView';
	    var form='schForm';
	    var action='../setting/fundInfo.php?method=listQry';    
        url = action;
        if (FundInfo.pg.params) {url +=FundInfo.pg.params;}
        submitSearch(form,url+rnd(),zone,function(){FundInfo.pg.init();});            
    }       		
     FundInfo.pg.query = FundInfo.search;

    
    //打开新增基金页面
    FundInfo.goAdd=function(){
        CM.open('../setting/fundInfo.php?method=add'+rnd(),{title:'新增基金',size:WINDOW_M},function(){
        	Help.show(732,1);
        });
    }

    //新增
    FundInfo.save = function(me){
       submitSave('fundAddForm','../setting/fundInfo.php?method=doAdd'+rnd(),function(){
    		CM.close(me);
    		FundInfo.search();
       });
    }
    
    //打开修改页面
    FundInfo.goEdit=function(oid){
        CM.open('../setting/fundInfo.php?method=edit&oid='+oid+rnd(),{title:'修改基金'},function(){
        });
    }
               
    //修改
    FundInfo.update = function(me){   
       submitSave('fundEditForm','../setting/fundInfo.php?method=doEdit'+rnd(),function(){
    		CM.close(me);
    		FundInfo.search();
       });      
    }

    //删除
    FundInfo.onDelete = function(oid){
       deleteRow('../setting/fundInfo.php?method=delete&oid='+oid+rnd(),function(){
    		FundInfo.search();
       });       
    }   
    
    //检查基金代码
    FundInfo.checkFundCode = function(fundCode){
        //alert($("#fundCode").val());
        if (fundCode.value==null||fundCode.value==''){
        	return;
        }
    
	    $.ajax({url:'../setting/fundInfo.php?method=checkFundCode'+rnd(),
	           type:"post",
	           dataType:"json",
	           data:'fundCode='+fundCode.value,	           
	           success:function(data){
//				       if (data.code!='0'){
//				          //alert('对不起,这个基金代码已经存在了.');				          
//				          CM.alert(data.msg);
//				       }
				       return;
			  }
	    });	    	    	    	        	
	}
    
    FundInfo.list = function(){
        $('#main').load('../setting/fundInfo.php?method=list'+rnd(),'',function(){  
        	Help.show(731,0);
           FundInfo.search();
        });
    }
    
    ///////////////////////////stock//////////////////////////////////////////////
	function StockInfo(){}
    StockInfo.pg = new Page('listtb');//列表页面
    //查询
    StockInfo.search = function(params){
	    var zone = 'dataView';
	    var form='schForm';
	    var action='../setting/stockInfo.php?method=listQry';    
        url = action;
        if (StockInfo.pg.params) {url +=StockInfo.pg.params;}
        submitSearch(form,url+rnd(),zone,function(){StockInfo.pg.init();});            
    }       		
    StockInfo.pg.query = StockInfo.search;

    
    //打开新增股票页面
    StockInfo.goAdd=function(){
        CM.open('../setting/stockInfo.php?method=add'+rnd(),{title:'新增股票代码',size:WINDOW_M},function(){
        	Help.show(730,1);
        });
    }

    //新增
    StockInfo.save = function(me){
       submitSave('stockAddForm','../setting/stockInfo.php?method=doAdd'+rnd(),function(){
    		CM.close(me);
    		StockInfo.search();
       });
    }
    
    //打开修改页面
    StockInfo.goEdit=function(oid){
        CM.open('../setting/stockInfo.php?method=edit&oid='+oid+rnd(),{title:'修改股票代码'},function(){
        });
    }
               
    //修改
    StockInfo.update = function(me){   
       submitSave('editForm','../setting/stockInfo.php?method=doEdit'+rnd(),function(){ 		 
    		CM.close(me);
    		StockInfo.search();
       });      
    }

    //删除
    StockInfo.onDelete = function(oid){
       deleteRow('../setting/stockInfo.php?method=delete&oid='+oid+rnd(),function(){
    		StockInfo.search();
       });       
    }   
    
    //检查股票代码
    StockInfo.checkStockCode = function(stockCode){
        //alert($("#stockCode").val());
        if (stockCode.value==null||stockCode.value==''){
        return;
        }
    
	    $.ajax({url:'../setting/stockInfo.php?method=checkStockCode',
	           type:"post",
	           dataType:"json",
	           data:'stockCode='+stockCode.value,	           
	           success:function(data){
				       return;
			  }
	    });	    	    	    	        	
	}
    
    StockInfo.list = function(){
        $('#main').load('../setting/stockInfo.php?method=list'+rnd(),'',function(){
        	Help.show(729,0);
           StockInfo.search();
        });
    }     

  
    // /////////////////////////////////////汇率/////////////////////////////////////////////////////////
	Exchange=function (){}
    Exchange.pg = new Page('exchangelisttb');// 列表页面
    // 查询
    Exchange.search = function(){
    	var form='schForm';
    	var zone='dataView';
	    var action='../setting/exchange.php?method=listQry';    
        url = action;
        if (Exchange.pg.params) {url +=Exchange.pg.params;}         
       	submitSearch(form,url+rnd(),zone,function(){Exchange.pg.init();})
    }
    Exchange.pg.query = Exchange.search;

    
    // 打开新增汇率页面
    Exchange.goAdd=function(){
        CM.open('../setting/exchange.php?method=add'+rnd(),{title:'新增汇率',size:WINDOW_M},function(){
        	Help.show(4043,1);
           $('#userName').click(function(){
                if ($(this).val()==''){
                   $(this).val($('#exchangeName').val());
                }
           })
			
        });
    }

    // 新增
    Exchange.save = function(me){
    	
       if($("#rate").val()<=0){
          CM.alert("汇率必须大于0！");
          $("#rate").val('1.0000');
          return;
       }
    	
       submitSave('exchangeAddForm','../setting/exchange.php?method=doAdd'+rnd(),function(){
    	   $('div#searchbar').find(":text[@name='payeeName']").val('');
    	   var currencyId=$('form#exchangeAddForm').find("select[name='currencyId']").val();
    	   //取到open页面的option，处理
    	   var opts=$("div#searchbar").find("select[name='currencyId']").find('option:first');
    	   opts.attr("selected","selected");
//    	   opts.each(function(){
//    		   if(this.value==currencyId){
//    			   $(this).attr("selected","selected");
//    			   CM.close(me);
//    			   Exchange.search();
//    			   return;
//    		   }
//    	   });
    	   CM.close(me);
           Exchange.search();
       });
       
    }
    
    // 打开修改页面
    Exchange.goEdit=function(oid){
        CM.open('../setting/exchange.php?method=edit&oid='+oid+rnd(),{title:'修改汇率',size:WINDOW_M},function(){
        	Help.show(4044,1);
        });
    }
               
    // 修改
    Exchange.update = function(me){
       submitSave('exchangeEditForm','../setting/exchange.php?method=doEdit'+rnd(),function(){
    		CM.close(me);
    		Exchange.search();
       });      
    }

    // 删除
    Exchange.onDelete = function(oid){
       deleteRow('../setting/exchange.php?method=delete&oid='+oid+rnd(),function(){
    		Exchange.search();
       });       
    }   
 
    Exchange.list = function(){
        $('#main').load('../setting/exchange.php?method=list'+rnd(),'',function(){ 
        	Help.show(4042,0);
           Exchange.search();
        });
    }
        


   ///////////////////////////config/////////////////////////////////////////////////////
	function Config(){}
	Config.pg = new Page('listtb');//列表页面  
	
	
    Config.list = function(){
        $('#main').load('../setting/config.php?method=list'+rnd(),'',function(){
        	Config.pg.init();
        	Help.show(4045,0);
        });
    }  
    
    Config.save = function(code){
        var val;
        switch (code){
            case 'fnPub':
                val= $('#fnPub').val();
            	break;
            case 'notePub':
                val= $('#notePub').val(); 
            	break;
            case 'showWriter':
                val= getRadioValue('showWriter');
            	break;
            default:
                CM.alert('未知的配置类型');
        }
               
        submitReq('../setting/config.php?method=doEdit&code='+code+'&value='+val+rnd(),function(data){
		            if (data.code=='0'){
		                CM.alert('修改成功.');
						//$('#msg').html('修改密码成功.');
		    		}else{
		    		    CM.alert(data.msg);
		    		    //$('#msg').html(data.msg);						    		
		    		}        
        });
           
    }
    
    Config.saveHelpSet = function(helpSet){
//    	var helpSet = getRadioValue('helpSet');
    	submitReq('../setting/config.php?method=doEditHelpSet&helpSet='+helpSet+rnd(),function(data){
    		if(data.code=='0'){
    			CM.alert('修改成功.');
    		}
    		if(helpSet=='0'){
    			$("div.tip_wrapper").show();
    		}else{
    			$("div.tip_wrapper").hide();
    		}
    		Config.list();
    	});
    }
    
    Config.saveShowWriter = function(){
    	var showWriter = getRadioValue('showWriter');
    	submitReq('../setting/config.php?method=doEditShowWriter&showWriter='+showWriter+rnd(),function(data){
    		if(data.code=='0'){
    			CM.alert('修改成功.');
    		}
    		Config.list();
    	});
    }
    
    Config.saveNotePub = function(){
    	var notePub = $('#notePub').val();
    	submitReq('../setting/config.php?method=doEditNotePub&notePub='+notePub+rnd(),function(data){
    		if(data.code=='0'){
    			CM.alert('修改成功.');
    		}
    		Config.list();
    	});
    }
      

   ////////////////////////////book/////////////////////////////////////////////////
	function Book(){}
    Book.pg = new Page('listtb');//列表页面
    //查询
    Book.search = function(){
	    var zone = 'dataView';
	    var form='schForm';
	    var action='../setting/book.php?method=listQry';    
        url = action;
        if (Book.pg.params) {url +=Book.pg.params;}        
        $('#dataView').load(url+rnd(),'',function(){
            Book.pg.init();
        });      
    }
    Book.pg.query = Book.search;
     
    Book.list = function(){
        $('#main').load('../setting/book.php?method=list'+rnd(),'',function(){  
           Help.show(4022,0);
           Book.search();
        });
    }

    
    //打开新增页面
    Book.goAdd=function(){
        CM.open('../setting/book.php?method=add'+rnd(),{title:'新增账本',size:WINDOW_M},function(){
        	Help.show(4023,1);
        });
    }

    //新增
    Book.save = function(me){
       submitSave('bookAddForm','../setting/book.php?method=doAdd'+rnd(),function(){
    		CM.close(me);
    		//page.refresh();
    		Book.search();
       });
    }
    
    //打开修改页面
    Book.goEdit=function(oid){
        CM.open('../setting/book.php?method=edit&oid='+oid+rnd(),{title:'修改账本',size:WINDOW_M},function(){
        	Help.show(4024,1);
        });
    }
               
    //修改
    Book.update = function(me){   
       submitSave('bookEditForm','../setting/book.php?method=doEdit'+rnd(),function(){
    		CM.close(me);
    		//page.refresh();
    		Book.search();
    		//更改了账本需要刷新header
    		$('div.container div.header').load('../global/header.php?'+rnd(),function(){
    			$('#header_setting').attr("class","active");
    		});
       });      
    }
    

    //删除
    Book.onDelete = function(oid){
       deleteRow1('../setting/book.php?method=delete&oid='+oid+rnd(),'您确定要删除吗？',function(){
    		Book.search();
       });       
    }   
    //设置为默认
    Book.setDefault = function(oid,isDefault){
    
//       if(!oid){
//    	   if(!getRdoVal('oid')){
//    		   CM.alert('请选择一条记录');
//    		   return;
//    		   
//    	   }
//    	   oid = getRdoVal('oid');
//       }
    	var alterIsDefault ;
    	if(isDefault=='1'){
    		alterIsDefault = '取消默认';
    	}else {
    		alterIsDefault = '设置为默认'; 
    	}
    	
       CM.confirm('设置成默认账本，会在登录以后自动打开，确定要'+alterIsDefault+'账本吗？',function(){
	       submitReq('../setting/book.php?method=setDefault&oid='+oid+rnd(),function(){
	    		Book.search();
	       }); 
       });           
    }   
    
    Book.goForward = function(){
    	
    	  CM.open('../setting/book.php?method=forward'+rnd(),{title:'结转账本',size:WINDOW_M},function(){
          	Help.show(4025,1);
          });
    	
//    	$('#main').load('../setting/book.php?method=forward'+rnd(),'',function(){         
//    		Help.show(728,0);
//         });
    }
  //执行结转
    Book.saveForward=function(me){
 	   var form='bookForwardForm';
 	   if(!validForm(form)) return;
 	   var action='../setting/book.php?method=doForward'+rnd();
 	  
 	   CM.confirm("确定结转吗？结转后的您的当前账本不可再结转，您可以到新账本记账",function(){
 		  submitSave(form,action,function(data){
 			  CM.close(me);
 			  Book.search();
 	 	   });
 	   });
 	   
    }
    
    Book.doRepair = function(oid){
    	CM.confirm('确认恢复该账本吗？',function(){
    		submitReq('../setting/book.php?method=repair&oid='+oid+rnd(),function(){
    			Recycle.search('bookRecycleQry');
    		});
    	});
    }
  
   
    /////////////////////////////category///////////////////////////////////////
	function Category(){}
	var categroyChange='4';
	Category.pg = new Page('listtb');//列表页面  
    Category.afterSave;
    Category.opener; //触发该页面的
    Category.pg.params='';

    //查询收支类别列表
    Category.search = function(cate){ 
    	$('#subjectCatehidden').val(cate);
		zone = 'dataView';
		form='categroySchForm';
		var val=cate;
	    if(cate=='3'){
	    	categroyChange=3;
	    }else{categroyChange=4;}
		action='../setting/category.php?method=listQry&subjectCate='+val+rnd();    
        url = action;
        if (Category.pg.params) {url +=Category.pg.params;}
        submitSearch(form,url+rnd(),zone,function(){
        	Category.pg.query = Category.search;
        	Category.pg.init();
        	});  
        
      //更改了账本需要刷新提示
		/*$('div.container div.header').load('../global/header.php?'+rnd(),function(){
			$('#header_setting').attr("class","active");
		});*/
    }       		
   
    //  
    Category.list = function(oid){
    	
        $('#main').load('../setting/category.php?method=list&subjectCate='+oid+rnd(),'',function(){  
        	Help.show(4026,0);
        	Category.search(oid);
        });
        /*url = "../setting/category.php?method=list";
        submitSearch('schForm',url+rnd(),'dataView',function(){
        	
        });*/
    }
	//切换收入、支出
	Category.changeCategory = function(me,n){
		
	    $(me).parents('div.winwrapper').load('../setting/category.php?method=add&subjectCate='+n+rnd(),'',function(){  
	    	if(n=='3'){
        		Help.show(4028,1);
        	}else{
        		Help.show(4029,1);
        	}
	    });
	    
	}
	Category.opener = '';//暂存select
	Category.params = ''; //暂存参数
    //打开新增收支类别页面
    Category.goAdd=function(me,params){
    	if(me){ //区分是否是其他页面新增
    		if($(me).val()!='add'){
    			return;
    		}
    		$(me).get(0).selectedIndex = 0;
    		Category.opener = me;
    		Category.params = params;
    	}
        CM.open('../setting/category.php?method=add&subjectCate='+categroyChange+rnd(),{title:'新增收支类别',size:WINDOW_M},function(){
        	if(categroyChange=='3'){
        		Help.show(4028,1);
        	}else{
        		Help.show(4029,1);
        	}
        	
        });       
    }
    
    //新增
    Category.save = function(me,subjectCate){
       submitSave('categoryAddForm','../setting/category.php?method=doAdd'+rnd(),function(){
    		CM.close(me);
    		if(Category.opener){
    			
    			$.getJSON(ctx+"/setting/category.php?method=getCategoryOption"+rnd(),Category.params,function(data){  
			         if (data.returnCode=='2'){
			        	var dataObj=eval(data.data);
			        	var options = '';
			        	$.each(dataObj,function(a,b){
			        		options=options+'<option value='+b.subjectId+'>'+b.subjectName+'</option>';
			        	})
			        	
			        	$(Category.opener).find('option').each(function(){
			        		if($(this).val()==''){
			        			options='<option value=>'+$(this).text()+'</option>'+options;
			        		}
			        		if($(this).val()=='add'){
			        			options=options+'<option value='+$(this).val()+'>'+$(this).text()+'</option>';
			        		}
			        	});
			        	$(Category.opener).empty();
			        	$(Category.opener).addClass($(Category.opener).attr('class')); //IE 下select的class需要重新加载
			    		$(Category.opener).append(options);
			         }
			    })
    			
    		}else{
    			Category.search(subjectCate);
        		if(subjectCate=='3'){
        			Tab.activeLi($('#subjectCateInCome'));
        		}else{
        			Tab.activeLi($('#subjectCateExpense'));
        		}
    		}
       });
    }
    
    //打开修改页面
    Category.goEdit=function(oid,subjectCate){
        //var subjectCate = getRdoVal('subjectCate');
        CM.open('../setting/category.php?method=edit&oid='+oid+rnd(),{title:'修改收支类别',size:WINDOW_M},function(){
        	if(subjectCate=='3'){
        		Help.show(4030,1);
        	}else{
        		Help.show(4031,1);
        	}
        	
        });
    }
    
        
    //修改
    Category.update = function(me,cate){
       submitSave('categoryEditForm','../setting/category.php?method=doEdit'+rnd(),function(){
    		CM.close(me);
    		//page.refresh();
    		Category.search(cate);
       });
    }

    //删除
    Category.onDelete = function(oid,cate){
       deleteRow1('../setting/category.php?method=delete&oid='+oid+rnd(),'确定要删除吗？',function(){
    		//CM.close(me);
    	  // Category.updateSort(cate);
    	   Category.search(cate);
    		
       });       
    }   

    //隐藏
    Category.hideIt = function(oid){
        if (!confirm('确定要隐藏吗？')){
           return;
        }
    
       submitReq('../setting/category.php?method=alterHide&invisible=1&oid='+oid+rnd(),function(data){
	            if (data.code!=0){
	              CM.alert(data.msg);
	              return;
	            }       
    		Category.search();
       });       
    }
    
    //取消隐藏
    Category.showIt = function(oid){
       submitReq('../setting/category.php?method=alterHide&invisible=0&oid='+oid+rnd(),function(){
    		Category.search();
       });       
    }
    
        //隐藏/取消
    Category.alterHide = function(oid,cate,isDefault,invisible){
//    	if(!oid){
//       	 if(getRadioValue('oid')){
//       		 oid=getRadioValue('oid')
//       	 }else{
//       		 return false;
//       	 }
//        }
    	if(isDefault==1){
    		CM.alert("默认账户不能设置为隐藏！");
    		 return;
    	}
    	var alterInvisible ;
    	if(invisible=='1'){
    		alterInvisible = '显示';
    	}else {
    		alterInvisible = '隐藏'; 
    	}
    	
    　　       CM.confirm('确认要'+alterInvisible+'该类别吗？',function(){
	       submitReq('../setting/category.php?method=alterHide&oid='+oid+rnd(),function(data){
	    		Category.search(cate);
	       });  
    　　       });
    }
        //日常收支/取消
    Category.alterDaily = function(oid){
    	
    	if(!oid){
          	 if(getRadioValue('oid')){
          		 oid=getRadioValue('oid')
          	 }else{
          		 return false;
          	 }
           }
//        if (!confirm('确定要设置/取消这个类别为日常收支吗？')){
//           return;
//        }       
    　　CM.confirm('确定要设置/取消这个类别为日常收支吗？',function(){
	       submitReq('../setting/category.php?method=alterDaily&oid='+oid+rnd(),function(data){
	            if (data.code!=0){
	              CM.alert(data.msg);
	              return;
	            }
	    		Category.search();
	       });  
       });
    }   
    
    //保存顺序
    Category.saveSort = function(){
        var subjectCate =$('#subjectCatehidden').val();
    	submitSave('categroySchForm','../setting/category.php?method=saveSort&subjectCate='+subjectCate+rnd(),function(){
     		Category.search(subjectCate);
       });      
    } 	
    
 // 恢复 
 	Category.doRepair= function(oid){
    	CM.confirm('确认恢复该收支类别吗?',function(){
    		submitReq('../setting/category.php?method=repair&oid='+oid+rnd(),function(data){
        		Recycle.search('categoryRecycleQry');
            });  
    	});
    }
 	
 	//设置或关闭默认
 	Category.alterDefault=function(oid,cate,invisible,isDefault){ 
    	if(invisible==1){
    		CM.alert("隐藏账户不能设置为默认！");
    		 return;
    	}
    	var alterIsDefault ;
    	if(isDefault=='1'){
    		alterIsDefault = '取消默认';
    	}else {
    		alterIsDefault = '设置为默认'; 
    	}
    	
    	CM.confirm('确定要'+alterIsDefault+'账户吗?',function(){
    		submitReq('../setting/category.php?method=alterDefault&oid='+oid+rnd(),function(){
    			Category.search(cate);
 	       });       
    	});
    }
 	
 	//显示隐藏类别列表
    Category.showHidden = function(oid,cate){ 
		zone = 'dataView';
		form='schForm';
		action='../setting/category.php?method=listQry&showInvisible='+cate+'&subjectCate='+oid;    
        url = action;
        if (Category.pg.params) {url +=Category.pg.params;}
        submitSearch(form,url+rnd(),zone,function(){Category.pg.init();});            
    }       		
    Category.pg.query = Category.search;

    //上移
    Category.moveUp= function(oid,cate){
    		submitReq('../setting/category.php?method=moveUp&categoryId='+oid+rnd(),function(data){
    			Category.search(cate);
            });  
    }
 	
  //下移
    Category.moveDown= function(oid,cate){
    		submitReq('../setting/category.php?method=moveDown&categoryId='+oid+rnd(),function(data){
    			Category.search(cate);
            });  
    }
    
    Category.updateSort = function (parm){ 
    	submitReq('../setting/category.php?method=updateSort&subjectCate='+parm+rnd(),function(data){
        }); 
    }
    
    
   ///////////////////////////account////////////////////////////////////
    Account = function(){}
    
    Account.pg = new Page('listtb');//列表页面
    Account.afterSave;

    //查询账户列表
    Account.pg.query=
    Account.search = function(cate){
	    var zone = 'dataView';
	    var form='schForm';
	    var action='../setting/account.php?method=listQry&showInvisible='+cate;
        url = action;
        if (Account.pg.params) {url +=Account.pg.params;}
        submitSearch(form,url+rnd(),zone,function(){Account.pg.init();});            
    }       		
    //Account.pg.query = Account.search;
    Account.list = function(){
        $('#main').load('../setting/account.php?method=list'+rnd(),'',function(){   
           Help.show(4001,0);
           Account.search();
        });
    }
    
    Account.params = '';//保存参数
    Account.opener = '';
    
    //打开新增账户页面
    //params是提交后查询账户的类型等条件。
    Account.goAdd=function(me,params){
    	if(me){ //区分是否是其他页面新增
    		if($(me).val()!='add'){
    			return;
    		}
    		//$(me).attr('onchange');
    		$(me).get(0).selectedIndex = 0;
    		Account.opener = me;
    		Account.params = params;
    	}
        CM.open('../setting/account.php?method=add'+rnd(),{title:'新增账户',size:WINDOW_L},function(){
        	Account.typeHelp('0');
        });
    }
    //新增
    Account.save = function(me,flag){
       submitSave('accountAddForm','../setting/account.php?method=doAdd'+rnd(),function(){
    		CM.close(me);
    		if(Account.opener){ //其他地方新增的账户要动态加载到selected中去
    			
    			$.getJSON(ctx+"/setting/account.php?method=getAccountOption"+rnd(),Account.params,function(data){  
			         if (data.returnCode=='2'){
			        	var dataObj=eval(data.data);
			        	var options = '';
			        	$.each(dataObj,function(a,b){
			        		if(b.currencyCode!=null){
				        		options=options+'<option value='+b.subjectId+'>'+b.subjectName+'('+b.currencyCode+')</option>';
			        		}else{
				        		options=options+'<option value='+b.subjectId+'>'+b.subjectName+'</option>';
			        		}
			        	})
			        	$(Account.opener).find('option').each(function(){
			        		if($(this).val()=='' && options==''){
			        			options='<option value=>'+$(this).text()+'</option>'+options;
			        		}
			        		if($(this).val()=='add'){
			        			options=options+'<option value='+$(this).val()+'>'+$(this).text()+'</option>';
			        		}
			        	});
			        	$(Account.opener).empty();
			        	$(Account.opener).addClass($(Account.opener).attr('class')); //IE 下select的class需要重新加载
			    		$(Account.opener).append(options);
			         }
			    })
    			
    		}else{
    			Account.search();
    			if(flag=='rarp'||flag=='stock'||flag=='fund'){
    				CM.afterSubmit1();
    			}
    		}
    		
       });      
    }
    
    //打开修改页面
    Account.goEdit=function(oid,accountType){  
         if(accountType=='5'){
    		CM.open('../setting/account.php?method=edit&oid='+oid+'&accountType='+accountType+rnd(),{title:'修改账户',size:WINDOW_G},function(){
            	Help.show(4017,1);
            });
         }else {
        	 CM.open('../setting/account.php?method=edit&oid='+oid+'&accountType='+accountType+rnd(),{title:'修改账户',size:WINDOW_M},function(){
             	switch (accountType){
        		case'0'://现金
        			Help.show(4012,1);
        			break;
        		case'1'://储蓄
        			Help.show(4013,1);
        			break;
        		case'3'://储值卡券
    				Help.show(4014,1);
    				break;
        		case'4'://重大资产
    				Help.show(4015,1);
    				break;
        		case'12'://在线支付
    				Help.show(4016,1);
    				break;
        		case'6'://应收款
    				Help.show(4018,1);
    				break;
        		case'7'://应付款
    				Help.show(4019,1);
    				break;	
        		case'9'://基金
    				Help.show(4021,1);
    				break;		
        		case'8'://证券账户
    				Help.show(4020,1);
    				break;
    			default:
    				return ;
        	}
             });
         }	
    }
    
        
    //修改
    Account.update = function(me){   
       submitSave('accountEditForm','../setting/account.php?method=doEdit'+rnd(),function(){
    		CM.close(me);
    		Account.search();
       });
    }

    //删除
    Account.onDelete = function(oid){
       deleteRow1('../setting/account.php?method=delete&oid='+oid+rnd(),'您确定要删除吗？',function(data){
    	   Account.search();
       });       
    }   

    //隐藏
    Account.hideIt = function(oid){
        if (!confirm('确定要隐藏吗？')){
           return;
        }
    
       submitReq('../setting/account.php?method=alterHide&invisible=1&oid='+oid+rnd(),function(){
    		Account.search();
       });       
    }   
    //取消隐藏
    Account.showIt = function(oid){
       submitReq('../setting/account.php?method=alterHide&invisible=0&oid='+oid+rnd(),function(){
    		Account.search();
       });       
    }   

    //隐藏/取消
    Account.alterHide = function(oid,isDefault,invisible){
    	
//    	if(!oid){
//        	if (!getRadioValue('oid')){
//        		return false;
//        	}
//        	oid=getRadioValue('oid');
//        }
    	if(isDefault==1){
    		CM.alert("默认账户不能设置为隐藏！");
    		 return;
    	}
    	
    	var alterInvisible ;
    	if(invisible=='1'){
    		alterInvisible = '显示';
    	}else {
    		alterInvisible = '隐藏'; 
    	}
    	
    	CM.confirm('确认要'+alterInvisible+'该账户吗？ 隐藏后，在记账时，该账户不再显示出来，但是在统计分析时，仍然会包含在内。如果确认该账户不再使用了，可以删除它，则以后不再进行统计分析。 ',function(){
        	submitReq('../setting/account.php?method=alterHide&oid='+oid+rnd(),function(){
	    		Account.search();
 	        });  
        });
    }   

    //设置或关闭默认
    Account.alterDefault=function(oid,invisible,isDefault){
    	if(invisible==1){
    		CM.alert("隐藏账户不能设置为默认！");
    		 return;
    	}
    	var alterIsDefault ;
    	if(isDefault=='1'){
    		alterIsDefault = '取消默认';
    	}else {
    		alterIsDefault = '设置为默认'; 
    	}
    	CM.confirm('确定要'+alterIsDefault+'账户吗?',function(){
    		submitReq('../setting/account.php?method=alterDefault&oid='+oid+rnd(),function(){
 	    		Account.search();
 	       });       
    	});
    }
    
    //保存顺序
    Account.saveSort = function(){
       submitSave('accountSchForm','../setting/account.php?method=saveSort'+rnd(),function(){
     		Account.search();
       });      
    } 
    
    //调整开户额
    Account.saveOpen = function(me){
       submitSave('addForm','../setting/open.php?method=doAdd'+rnd(),function(){
    		CM.close(me);
    		Account.search();
       });      
    }
      
    //初始化页面
    Account.goOpen = function(oid,accountType){
    	
    	    if(accountType=="6" || accountType=="7"){
    	    	CM.open('../setting/account.php?method=loadAddInitCnt&accountId='+oid+rnd(),{title:'调整初始余额',size:WINDOW_G},function(){
 		         });
    	    } else if(accountType=="8" || accountType=="9"){
    	    	CM.open('../setting/open.php?method=loadFundStockAddInitCnt&accountId='+oid+'&accountType='+accountType+rnd(),{title:'调整初始余额',size:WINDOW_G},function(){
 		         });
    	    }else {
		        CM.open('../setting/open.php?method=add&accountId='+oid+rnd(),{title:'调整初始余额'},function(){
		         
		        });
    	    }
    }
    
  //修改开户金额
    Account.editOpen = function(me){
       $('#msg').html('正在保存，请稍候...');   
       submitSave('editForm','../setting/open.php?method=doEdit'+rnd(),function(){
    		CM.close(me);
    		CM.afterSubmit0();
    		CM.afterSubmit();
       });      
    }
    
    
 // 恢复 
 	Account.doRepair= function(oid){
    	CM.confirm('确认恢复该账户吗?',function(){
    		submitReq('../setting/account.php?method=repair&oid='+oid+rnd(),function(data){
        		Recycle.search('accountRecycleQry');
            });
    	});
    }
 	
 	 Account.typeHelp=function(atm){
    	switch (atm){
    		case'0'://现金
    			$("#account_tip_content").html('现金账户用于处理您的现金收入、消费等活动，可以理解为您的钱包。');
    			break;
    		case'1'://储蓄
    			$("#account_tip_content").html('普通储蓄存折、借记卡、定期存款等，目前不区分定活期。');
    			break;
    		case'3'://储值卡券
    			$("#account_tip_content").html('诸如购物券、超市券等可以支付购买物品的东西或会员卡，公交卡，手机卡等可以充值的东西。');
				break;
    		case'4'://重大资产
    			$("#account_tip_content").html('诸如房产，汽车等固定资产。用这个账户，管理它的升贬值等变化。比如你可以为你的房子建个账户，叫：我的房产，余额代表它的目前市值。');
				break;
    		case'12'://在线支付
    			$("#account_tip_content").html('在线支付账户指卖方与买方通过因特网上的电子商务网站进行交易时，银行为其提供网上资金结算服务的一种业务。像支付宝等。');
				break;
    		case'5'://信用卡
    			$("#account_tip_content").html('可透支的贷记卡。余额代表您已经透支的额度. 但并不是指最大可用额度.透支额如果为负数，表示信用卡内的存款。');
				break;
    		case'6'://应收款
    			$("#account_tip_content").html('用户与他人之间由于交易而形成的各种应收未收的债权，包括应收票据、应收账款等。余额是指目前已有的应收款。');
				break;
    		case'7'://应付款
    			$("#account_tip_content").html('通常指应付帐款、应付票据和其他应付款。代表你的债务。余额是指目前已有的应付款。');
				break;	
    		case'9'://基金
    			$("#account_tip_content").html('基金账户在这里是指记录您进行基金活动的账户。实际记账时候还需要使用相应的资金账户。');
				break;		
    		case'8'://证券账户
    			$("#account_tip_content").html('证券账户这里通常指记录股票交易的账户，代表股票市值.不含可支配的资金。您在进行股票活动时，还需要使用相应的资金账户。');
				break;
			default:
				return ;
    	}
    }
 	 
 	
  	//根据账户类型 选择相应的页面
  	Account.nextPage = function(me){
  		var accountType = $("input[name='accountType']:checked").val(); 
  		if(accountType=='5'){
	  		CM.open('../setting/account.php?method=loadAddCnt&accountType='+accountType+rnd(),{title:'新增账户',size:WINDOW_G},function(){
	  			    CM.close(me);
		         });
  		}else{
  			CM.open('../setting/account.php?method=loadAddCnt&accountType='+accountType+rnd(),{title:'新增账户',size:WINDOW_M},function(){
  			    CM.close(me);
	         });
  		}
//  	    $('#account_add_page').load('../setting/account.php?method=loadAddCnt&accountType='+accountType+rnd(),'',function(){  
//  	     });
     }
  	
  	Account.broRemind = function (){
  			 CM.confirm("您是否需要对刚刚新增的账户进行初始化操作！" 
  		 			,function(){
  		 				CM.open('../setting/account.php?method=loadAddInitCnt'+rnd(),{title:'应收应付初始化',size:WINDOW_G},function(){
  		 		 			
  		 		         });
  		 			}	 
  		 		 );
  	}
  	
  	Account.stockRemind = function (){
  		 CM.confirm("您是否需要对刚刚新增的账户进行初始化操作！" 
		 			,function(){
		 			CM.open('../setting/open.php?method=loadFundStockAddInitCnt'+rnd(),{title:'调整初始余额',size:WINDOW_G},function(){
			        
		 			});
		 			}	 
		 		 );
  	}
  	
  	
  	Account.fundRemind = function (){
  		 CM.confirm("您是否需要对刚刚新增的账户进行初始化操作！" 
		 			,function(){
		 			CM.open('../setting/open.php?method=loadFundStockAddInitCnt'+rnd(),{title:'调整初始余额',size:WINDOW_G},function(){
			 		 
			         });
		 			}	 
		 		 );
  	}
  	
  	Account.showSubName = function(me){
  		
  		var subjectName= $("input[name='BankType']:checked").val();
  	    $("#bankType").val(subjectName); 
  	}
  	
  	
  	Account.addMoreBank = function (me){ 
        var subjectName= $("input[name='BankTypeMore']:checked").val();
  		var bankName = $("#bankType").val(subjectName); 
  		$("input[name='BankType']:checked").removeAttr('checked');
  		CM.close(me);
  	}
  	
  	Account.showMoreBank = function(){
  		 CM.open('../setting/account.php?method=showMoreBank'+rnd(),{title:'更多银行',size:WINDOW_G},function(){
 			Help.show(702,1);
         });
  	}
  	
  	 //按钮 上一步
    Account.goBack=function(me){
        CM.open('../setting/account.php?method=add'+rnd(),{title:'新增账户',size:WINDOW_L},function(){
        	  CM.close(me);
        	  Account.typeHelp('0');
			
        });
    }
    
   // 应收 应付账户 初始化
    Account.doArapAdd = function(me){
 		  submitSave('addForm','../setting/account.php?method=doArapAdd'+rnd(),function(date){
 			  if(date.returnCode!='1'){
 				  CM.close(me);
 			  }
 			  Account.search();
 		  });
    }
    //信用卡　初始化
    Account.noticeChange = function (me,parm){
    	if(parm=='close'){
	    	$(me).parents('tr:first').nextAll('tr').each(function(){
	    		$(this).find('select').attr('disabled',true);
	    		$(this).find('input').attr('disabled',true);
	    	});
    	}else if(parm=='open'){ 	
    		$(me).parents('tr:first').nextAll('tr').each(function(){ 
	    		$(this).find('select').removeAttr('disabled');
	    		$(this).find('input').removeAttr('disabled');
	    	});
    		
    	}
    }
    //已透支额不能大于透支限额
    Account.checkAmount = function (){
	    var initAmount = $("#init_Amount").val();
	    var coAmount   = $("#co_Amount").val();
	    if(Number(initAmount)>Number(coAmount)){
	 	  CM.alert("已透支额不能大于透支限额！");
	    }
    }
   
    //新增信用卡账户
    Account.saveCredit = function(me){ 
    	var initAmount = $("#init_Amount").val();
 	    var coAmount   = $("#co_Amount").val();
 	    if(Number(initAmount)>Number(coAmount)){
 	 	  CM.alert("已透支额不能大于透支限额！");
 	 	  return;
 	    }
       submitSave('accountAddForm','../setting/account.php?method=doCreditAdd'+rnd(),function(){
    	   CM.close(me);
    	   //CM.alert(Account.opener);
    	   if(Account.opener){ //其他地方新增的账户要动态加载到selected中去
			
			$.getJSON(ctx+"/setting/account.php?method=getAccountOption"+rnd(),Account.params,function(data){  
		         if (data.returnCode=='2'){
		        	var dataObj=eval(data.data);
		        	var options = '';
		        	$.each(dataObj,function(a,b){
		        		if(b.currencyCode!=null){
			        		options=options+'<option value='+b.subjectId+'>'+b.subjectName+'('+b.currencyCode+')</option>';
		        		}else{
			        		options=options+'<option value='+b.subjectId+'>'+b.subjectName+'</option>';
		        		}
		        	})
		        	$(Account.opener).find('option').each(function(){
		        		if($(this).val()=='' && options==''){
		        			options='<option value=>'+$(this).text()+'</option>'+options;
		        		}
		        		if($(this).val()=='add'){
		        			options=options+'<option value='+$(this).val()+'>'+$(this).text()+'</option>';
		        		}
		        	});
		        	$(Account.opener).empty();
		        	$(Account.opener).addClass($(Account.opener).attr('class')); //IE 下select的class需要重新加载
		    		$(Account.opener).append(options);
		         }
		    })
			
    	   }else{
    		   Account.search();
    	   }
       }); 
       
    }
    
    //账单日  还款日
    Account.setDay = function (me,parm){
    	if(parm=='1'){
    	   $(me).parents('tr:first').find('select').attr('disabled',true);
    	   $(me).parents('td:first').find('input:hidden').val('-1');
    	}else if (parm=='2'){
           $(me).parents('tr:first').find('select').removeAttr('disabled');
    	}else if(parm=='3'){
    	   $(me).parents('td').next('td').find('select').attr('disabled',true);
    	   $(me).parents('td:first').find('select').removeAttr('disabled');
    	}else if(parm=='4'){
    	   $(me).parents('tr:first').find('select').attr('disabled',true);
    	   $(me).parents('td:first').find('select').removeAttr('disabled');
    	}
    }
    
    //信用卡账户 执行编辑
    Account.creditEdit = function (me){
    	var initAmount = $("#initAmount").val();
 	    var coAmount   = $("#coAmount").val();
 	    
 	    if(Number(initAmount)>Number(coAmount)){
 	 	  CM.alert("已透支额不能大于透支限额！");
 	 	  return;
 	    }
    	 submitSave('CreditEditForm','../setting/account.php?method=doCreditEdit'+rnd(),function(){
     		CM.close(me);
     		Account.search();
        });
    }
    //应收应付 
    Account.RAPEdit = function (me){
    	submitSave('RAPEditForm','../setting/account.php?method=doRAPEdit'+rnd(),function(){
     		CM.close(me);
     		Account.search();
        });
    }
    //新增基金初始化
    Account.doFundAdd = function(me){
      	if($('#fundCode0').val()!=''||$('#price0').val()!=''||$('#quantity0').val()!=''){
    		$('#fundCode0').attr('notnull',true);
    		$('#price0').attr('notnull',true);
    		$('#quantity0').attr('notnull',true);
    	}
    	
       submitSave('foundInitForm','../setting/open.php?method=doFundAdd'+rnd(),function(date){
    		if(date.returnCode!='1'){
    			 CM.close(me);
    		  }
    		Account.search();
       });
    }
    //基金初始化编辑
    Account.doFundEdit = function(me){
    	
     	if($('#fundCode0').val()!=''||$('#price0').val()!=''||$('#quantity0').val()!=''){
     		$('#fundCode0').attr('notnull',true);
     		$('#price0').attr('notnull',true);
     		$('#quantity0').attr('notnull',true);
     	}
    	
    	 submitSave('foundInitEditForm','../setting/open.php?method=doFundInitedit'+rnd(),function(date){
    		 if(date.returnCode!='1'){
    			 CM.close(me);
    		  }
     		Account.search();
        });
    }
    //股票初始化新增
    Account.doStockAdd = function(me){
    	
    	
	if($('#stockCode0').val()!=''||$('#price0').val()!=''||$('#quantity0').val()!=''){
 		$('#stockCode0').attr('notnull',true);
 		$('#price0').attr('notnull',true);
 		$('#quantity0').attr('notnull',true);
 	}
    	
    	
   	 submitSave('stockAddForm','../setting/open.php?method=doStockAdd'+rnd(),function(date){
   		if(date.returnCode!='1'){
			 CM.close(me);
		  }
  		Account.search();
     });
   }
    //股票初始化编辑
    Account.doStockEdit = function(me){
    	if($('#stockCode0').val()!=''||$('#price0').val()!=''||$('#quantity0').val()!=''){
     		$('#stockCode0').attr('notnull',true);
     		$('#price0').attr('notnull',true);
     		$('#quantity0').attr('notnull',true);
     	}
    	 submitSave('stockEditForm','../setting/open.php?method=doStockInitedit'+rnd(),function(date){
    		 if(date.returnCode!='1'){
    			 CM.close(me);
    		  }
     		Account.search();
        });
    }
////////////////////////////////Recycle//////////////////////////////////////////////
    Recycle = function(){}
    Recycle.payeePg=new Page('listtb');
    Recycle.tagPg=new Page('listtb');
    Recycle.subjectPg=new Page('listtb');
    
    Recycle.list=function(){
	   	   $('#main').load('../setting/recycle!list.php?'+rnd(),'',function(){
	   		   	   Recycle.find('subject');//默认显示账目回收页
	   		   	   Help.show(4046,0);
	   	   });
    }
    
    Recycle.find=function(cate){//子页签的主界面
 	   $('#searchView').load('../setting/recycle!'+cate+'RecycleList.php?'+rnd(),'',function(){
 		   if(cate=='payee'){
 			   Recycle.payeeSearch();
 		   }else if(cate=='tag'){
 			   Recycle.tagSearch();
 		   }else if(cate=='subject'){
 			   Recycle.subjectSearch();
 		   }else{
 		       Recycle.search(cate+'RecycleQry'); 
 		   }
 	   });
    }
    
  //不要分页
    Recycle.search=function(cate){
      var zone = 'dataView';
 	  var form='schForm';
 	  var action='../setting/recycle!'+cate+".php?";   
      url = action;
      submitSearch('schForm',url+rnd(),zone,function(){
    	  Recycle.subjectPg.init();
     	// Recycle.pg.query=Recycle.search(cate);
      });
    }
    
    //账目回收站数据列表,带分页
    Recycle.subjectSearch=function(){
 	     var action='../setting/recycle!subjectQryByAccount.php?';  
// 	   	 var qryCate=$('#qryCate').val();
// 	   	 if(qryCate=='1'){
// 	   		 action='../setting/recycle!subjectQryByCategory.php?';  
// 	   	 }
 		 var zone = 'dataView';
 		 var form='entrySchForm';
 	     url = action;
 	     if (Recycle.subjectPg.params) {url +=Recycle.subjectPg.params;}        
 	     submitSearch('entrySchForm',url+rnd(),zone,function(){Recycle.subjectPg.init();});
    }
    Recycle.subjectPg.query=Recycle.subjectSearch;
   
  //人员回收站,带分页
    Recycle.payeeSearch=function(){
 		 var zone = 'dataView';
 		 var form='schForm';
 		 var action='../setting/recycle!payeeRecycleQry.php?';   
 	     url = action;
 	     if (Recycle.payeePg.params) {url +=Recycle.payeePg.params;}        
 	     submitSearch('schForm',url+rnd(),zone,function(){Recycle.payeePg.init();});
 	}
    
    Recycle.payeePg.query=Recycle.payeeSearch;
    
  //项目回收站数据列表,带分页
    Recycle.tagSearch=function(){
 		 var zone = 'dataView';
 		 var form='schForm';
 		 var action='../setting/recycle!tagRecycleQry.php?';   
 	     url = action;
 	     if (Recycle.tagPg.params) {url +=Recycle.tagPg.params;}        
 	     submitSearch('schForm',url+rnd(),zone,function(){Recycle.tagPg.init();});
    }
    
    Recycle.tagPg.query=Recycle.tagSearch;
    
    

    //账目回收站数据列表,带分页
    Recycle.accountsSearch=function(){
 	     var action='../setting/recycle!accountsQry.php?';  
 		 var zone = 'dataView';
 		 var form='entrySchForm';
 	     url = action;
 	     if (Recycle.subjectPg.params) {url +=Recycle.subjectPg.params;}        
 	     submitSearch('entrySchForm',url+rnd(),zone,function(){Recycle.subjectPg.init();});
    }
    Recycle.subjectPg.query=Recycle.subjectSearch;
    
///////////////////////////////////skin//////////////////////////////////////////   
   Skin = function(){}
   Skin.doChange = function(skinId,skinName){
	  // var skinId=getRadioValue(radioName);
	   CM.confirm("是否立即应用"+skinName+"皮肤？",function(){
		   submitReq('../setting/skin!doChange.php?skinId='+skinId+rnd(),function(){
			   //window.location.href="../setting/index.php?subModule=Skin";
			   window.location.reload(); 
		   }); 
	   });
	   
   }
//////////////////////////note///////////////////////////////////////////
	function Note(){}   
   Note.pg = new Page('listtb');//列表页面
   //查询
   Note.search = function(){
	    var zone = 'dataView';
	    var form='schForm';
	    var action='../setting/note.php?method=listQry';
       url = action;
       if (Note.pg.params) {url +=Note.pg.params;}
       submitSearch(form,url+rnd(),zone,function(){Note.pg.init();});            
   }       		
   Note.pg.query = Note.search;

   
   //打开新增记事页面
   Note.goAdd=function(){
       CM.open('../setting/note.php?method=add'+rnd(),{title:'新增记事',size:WINDOW_G},function(){
       	Help.show(4053,1);
       });
   }

   //新增
   Note.save = function(me){
      submitSave('addForm','../setting/note.php?method=doAdd'+rnd(),function(){
   		CM.close(me);
   		Note.list();
      });
   }
   
   //打开修改页面
   Note.goEdit=function(oid){
       CM.open('../setting/note.php?method=edit&oid='+oid+rnd(),{title:'修改记事',size:WINDOW_G},function(){
       	Help.show(4054,1);
       });
   }
              
   //修改
   Note.update = function(me){   
      submitSave('editForm','../setting/note.php?method=doEdit'+rnd(),function(){
   		CM.close(me);
   		Note.search();
      });      
   }

   //查看记事
   Note.view=function(noteId){
       var url = '../setting/note.php?method=view&noteId='+noteId+rnd();
       $('#main').load(url,'',function(){
           //pg.init();
       });      
   }
   
   //删除
   Note.onDelete = function(oid){
      deleteRow('../setting/note.php?method=delete&oid='+oid+rnd(),function(){
   		Note.search();
      });       
   }
   
   //打开回复的页面
   Note.goReply=function(oid){
       CM.open('../setting/note.php?method=reply&oid='+oid+rnd(),{title:'回复记事'},function(){
       });
   }
   
   //回复
	Note.saveReply=function(){
	   if ($('#content').val()==''){
	      CM.alert('正文不能为空！');
	      $('#content').focus();
	      return;     
	 }   
	 	document.replyForm.submit();	   
	}
   
   Note.list = function(){
   	
       //$('#main').load('../planning/note.php?method=list'+rnd(),'',function(){   
       //$('#main').load('../planning/noteList.jsp');
       $('#main').load('../setting/note.php?method=list'+rnd(),'',function(){  
       	Help.show(4052,0);
          Note.search();
       });        
   }

   
   